﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SharedGenomics.Workbench.Core;
using SharedGenomics.Annotations;

namespace SharedGenomics.Workbench.Presenters
{
    public class WebSearchableAnnotationMenuProvider : IAnnotationMenuProvider
    {
        public WebSearchableAnnotationMenuProvider(CommandFactory commandFactory, IMenuFactory menuFactory)
        {
            this.CommandFactory = commandFactory;
            this.MenuFactory = menuFactory;
        }

        public IMenuItem CreateMenu(IAnnotation annotation)
        {
            IWebSearchable webAnnotation = (IWebSearchable)annotation;
            IMenuItem menuItem = this.MenuFactory.CreateContextMenuItem();

            //setup menu item
            menuItem.DisplayText = webAnnotation.SummaryText;
            menuItem.Command = this.CommandFactory.CreateOpenUriAnnotationCommand(webAnnotation.SearchUri, annotation);

            return menuItem;
        }

        public Type AnnotationType
        {
            get { return typeof(IWebSearchable); }
        }

        private CommandFactory CommandFactory { get; set; }
        private IMenuFactory MenuFactory { get; set; }
    }
}
